<script type="text/javascript">

$j('.commentTextarea').live("keypress", function(e){
	if(e.keyCode == 13) {
		var textarea = $j(this);
		var target = $j(this).parent().parent();
		var commentTargetType = $j(this).attr('targetType');
		var commentTargetID = $j(this).attr('targetID');		
		var commentValue = $j(this).val();

		$j.ajax({
			type : "POST",
			url : "<?php bloginfo('template_url'); ?>/ajax/doAction.php",
			data : "actionName=addComment&target_type="+commentTargetType+"&target_id="+commentTargetID+"&comment="+commentValue,
		});

		// suppression de l'ancienne zone contenant les commentaires.
		target.prev().remove();
		
		// rechargement du contenu
		$j.ajax({
			type : "POST",
			url : "<?php bloginfo('template_url'); ?>/ajax/getContent.php",
			data : "functionName=getAllComments&publicationType="+commentTargetType+"&publicationID="+commentTargetID+"",
			success:function(response){
				target.before(response);
				textarea.val("");
			}
		});
	}
});

</script>